//
//  ListPresenter.m
//  ViperDemo
//
//  Created by Leeesven on 17/5/17.
//  Copyright © 2017年 Leeesven. All rights reserved.
//

#import "ListPresenter.h"
#import "ListViewInterface.h"

#import "UpcomingDisplayData.h"
#import "UpcomingDisplayDataCollector.h"

@implementation ListPresenter

-(void)updateView{
    [self.listInteractor findUpcomingItems];
}

#pragma mark --
-(void)foundUpcomingItems:(NSArray *)upcomingItems{
    if ([upcomingItems count] == 0)
    {
        [self.userInterface showNoContentMessage];
    }
    else
    {
        [self updateUserInterfaceWithUpcomingItems:upcomingItems];
    }
}

- (void)updateUserInterfaceWithUpcomingItems:(NSArray *)upcomingItems{
    [self.userInterface showUpcomingDisplayData:[self upcomingDisplayDataWithItems:upcomingItems]];
}

- (UpcomingDisplayData *)upcomingDisplayDataWithItems:(NSArray *)upcomingItems
{
    UpcomingDisplayDataCollector *collector = [[UpcomingDisplayDataCollector alloc] init];
    [collector addUpcomingItems:upcomingItems];
    
    return [collector collectedDisplayData];
}

#pragma mark -
-(void)addNewEntry{
    
}

@end
